from pmcore.basecom import BaseComponent

class Translator(BaseComponent):
    name = "Base event translator"
    author = "Ninth"
    version = "1.0"
    weight = 100
    def __init__(self):
        BaseComponent.__init__(self)
        self.provides = ({"name":"event-translator-has-event",
                        "value":self.has_event,
                        "version":"1.0"},)

    def after_direct_import(self):
        for key,value in self.settings.items():
            if value.lower() == "true":
                base.accept(key,self.transmit,[key])

    def transmit(self,evt):
        send_event(evt)

    def has_event(self,name):
        res = False
        if self.settings.has_key(name):
            if self.settings[name].lower() == "true":
                res = True
        return res
